package role_menu

import (
	"Server/internal/service"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/util/gconv"
)

type sRoleMenu struct {
	tableName string
}

func init() {
	service.RegisterRoleMenu(New())
}
func New() *sRoleMenu {
	return &sRoleMenu{
		tableName: "sys_role_menu",
	}
}

//GetRoleMenus 获取所有菜单信息
func (logic *sRoleMenu) GetRoleMenus() {

}

//GetRoleMenusByRoleId 获取角色对应的菜单信息
func (logic *sRoleMenu) GetRoleMenusByRoleId(roleId int) g.Map {
	record, err := g.Model(logic.tableName).Where("RoleId", roleId).One()
	if err != nil || record == nil {
		return nil
	}
	result := g.Map{}
	gconv.Struct(record, &result)
	return result
}
